using RBAC.Write.API.Commonts;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddServices(builder.Configuration);
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.ConsulRegister(option =>
{
    var consuConfig = builder.Configuration.GetSection("ConsulConfig").Get<ConsulConfig>();
    consuConfig.ServicePort = int.Parse(builder.Configuration["port"] ?? "5000");

    option.Config(consuConfig);
});
var app = builder.Build();

// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
    app.UseSwagger();
    app.UseSwaggerUI();
//}

app.UseAuthorization();
app.UseConsul(builder.Services.BuildServiceProvider(), app.Lifetime);
app.MapControllers();
app.UseCors(x=>x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
app.Run();
